package cn.pn.project.client.user;

import cn.pn.project.client.user.fallback.UserFeignFallback;
import cn.pn.project.pojo.user.User;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(name = "pn-user-provider",fallback = UserFeignFallback.class)
@RequestMapping("/user")
public interface UserFeign {
    /**
     * 根据userId 修改i用户余额
     *
     * @param u
     * @return
     */
    @PostMapping("updateUserBalance")
    Boolean updateUserBalance(@RequestBody User u);

    /**
     * 根据用户id 修改用户积分
     *
     * @param u
     * @return
     */
    @PostMapping("updateUserIntegral")
    Boolean updateUserIntegral(@RequestBody User u);

    /**
     * 获取用户信息
     *
     * @param userId
     * @return
     */
    @PostMapping("findUserById")
    User findUserById(@RequestBody Integer userId);

    /**
     * 修改用户信息
     *
     * @param user 所有信息都必须有 id 不能改变
     * @return
     */
    @PostMapping("updateUser")
    Boolean updateUser(@RequestBody User user);

    /**
     * 根据手机号码加密码登陆
     *
     * @param user 手机号 密码
     * @return 返回boolean值
     */
    @PostMapping("findByPhoneAndPassword")
    User findByPhoneAndPassword(@RequestBody User user);

    /**
     * 添加用户
     *
     * @param user
     * @return
     */
    @PostMapping("insertUser")
    Boolean insertUser(@RequestBody User user);

    /**
     * 根据手机号查询用户
     *
     * @param telephone
     * @return
     */
    @PostMapping("findByTelephone")
    User findByTelephone(@RequestParam("telephone") String telephone);

    /**
     * 更新用户登陆时间
     *
     * @param userId
     * @return
     */
    @PostMapping("updateLoginTimeByUserId")
    Boolean updateLoginTimeByUserId(@RequestBody Integer userId);
}
